﻿using Microsoft.Practices.Unity.InterceptionExtension;
using Sapit.Attributes.Interfaces;

namespace Sapit.Unity.Attributes
{
    /// <summary>
    /// Apply this attribute to methods that should have timeout.
    /// </summary>
    public class TimeoutAttribute : HandlerAttribute, ITimeout
    {
        /// <summary>
        /// Maximum number of milliseconds before throwing an exception
        /// </summary>
        public double TimeoutMilliseconds { get; set; }

        public override ICallHandler CreateHandler(Microsoft.Practices.Unity.IUnityContainer container)
        {
            return new TimeoutHandler();
        }
    }
}
